home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ETO Development Tools 4
/
ETO Development Tools 4.iso
/
Tools - Objects
/
Virtual User 1.0
/
Example Libraries
/
StandardDialogsLib.vu
< prev
next >
Wrap
Text File
|
1991-01-25
|
2KB
|
58 lines
#
# File: StandardDialogs.vu
#
# Contains: Sample tasks for working with standard Macintosh dialogs
#
# Written by: Sean Flynn, Jay Jessen, and P. Nagarajan
#
# Copyright: © 1990 by Apple Computer, Inc., all rights reserved.
#
# Change History:
#
# 4/25/89 SLF Created.
#
# To Do:
#
# *****************************************************************************************
# Handle a simple case of work with the Standard file dialog.
task DoSaveAs( save_title := 'Untitled' ) begin
select [menuItem t: "Save As"]; #menu selection
type k:{ save_title }; #literal key strokes
select [button t:"Save"]; #button press
# if the file exists, the "Do you want to replace dialog will come up
# This if statement recognizes that dialog and deals with it
if match[window s:dialog k:{ [button t:"Yes"], [button t:"No"] } ] do
select[button t:"Yes"];
end; # task DoSaveAs
# *****************************************************************************************
task SelectFromStandardFile(path_to_file,maximum_nesting_depth := 64) begin
# This task will select a file from the standard file dialog. It
# navigates through the dialog by way of the keyboard.
# It takes two parameters, one is a list of file prefixes that will take
# the virtual user down to the file you want selected. The list must
# contain the strings that VU can type to reach the file. They may be the
# complete folder names or enough of the folder name to distinguish them
# from sibling folders. The second is a number indicating the current
# directory's maximum depth. VU uses this number to get up to the top using
# command-up arrow. By default, it is 64 so it isn't necessary to pass
# the second parameter. The operation may be made faster, however, if you
# pass it a smaller number. A sample call might look like this:
#
# SelectFromStandardFile( { "HD","MPW","Interf","Cinclu","Palettes" },10 );
#
pressKey keystrokes: { commandKey };
for i := 1 to maximum_nesting_depth type keystrokes: { upArrowKey };
releaseKey keystrokes: { commandKey };
path_size := card(path_to_file);
for i := 2 to path_size - 1 type keystrokes: { path_to_file[i],returnKey };
type keystrokes: { path_to_file[path_size] };
end;
(* Example Usage:
SelectFromStandardFile( { "HD","MPW","Interf","Cinclu","Palettes" },10 );
DoSaveAs("junk");
*)